package com.shoponline.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.shoponline.dao.ShippingAddrDAO;
import com.shoponline.po.Shippingaddr;

public class ShippingAddrDaoImpl extends HibernateDaoSupport implements ShippingAddrDAO{

	@Override
	public void addShiipingAddr(Shippingaddr shippingaddr) {
		
		this.getHibernateTemplate().save(shippingaddr);
		
	}

	@Override
	public void deletShiipingAddr(Shippingaddr shippingaddr) {
		
		this.getHibernateTemplate().delete(shippingaddr);
		
	}

	@Override
	public void updateShiipingAddr(Shippingaddr shippingaddr) {
		
		this.getHibernateTemplate().update(shippingaddr);
		
	}

	@Override
	public Shippingaddr load(Serializable id) {
	
		return  this.getHibernateTemplate().load(Shippingaddr.class, id);
	}

	@Override
	public Shippingaddr selectShippingaddr(String shipiaddrid) {
		
		List<Shippingaddr> list = this.getHibernateTemplate().find("from shippingaddr where SHIPADDRID=?",shipiaddrid);
		Shippingaddr shippingaddr = null;
		if(list.size()>0){
			
			shippingaddr = (Shippingaddr) list.get(0);
			
		}
		
		return shippingaddr;
	}
	
}
